import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

//全局引入
import '@/assets/scss/reset.scss'
import 'element-ui/lib/theme-chalk/index.css'
//第三方
import ElementUI from 'element-ui'
import http from './api/config'
import mock from './mock'
import Cookie from 'js-cookie'
//绑定在全局的vue中，直接可以this.$http来访问
Vue.prototype.$http=http
router.beforeEach((to, from, next) => {
  const cookie=Cookie.get('token')
  //1.没有cookie则跳转login界面
  //2.跳转的页面不能是login页面。
  if(to.name !== 'login' && !cookie) next({ name: 'login' })
  else next()
})

Vue.config.productionTip = false
Vue.use(ElementUI)


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
